//
//  VELoginOutTableViewCell.m
//  VEMoneyPorject
//
//  Created by BlueWind on 2018/9/14.
//  Copyright © 2018年 陈建. All rights reserved.
//

#import "VELoginOutTableViewCell.h"

@implementation VELoginOutTableViewCell

{
    UIButton *_loginButton;
}

/** 返回循环利用的cell */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self= [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor colorWithHexString:kCommonBgColor];
        [self loadDefaultSetting];
    }
    return self;
}

/** 加载默认UI元素和需要的数据 */
- (void)loadDefaultSetting {
    
    UIButton *loginButton = [UIButton new];
    _loginButton = loginButton;
    [self.contentView addSubview:loginButton];
    [loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.contentView);
        make.height.mas_equalTo(30);
    }];
    loginButton.contentEdgeInsets = UIEdgeInsetsMake(5, GAP15, 5, GAP15);
    [loginButton setTitle:@"退出本群" forState:(UIControlStateNormal)];
    [loginButton setLayerCornerRadius:15];
    [loginButton setTitleColor:[UIColor redColor] forState:(UIControlStateNormal)];
    loginButton.backgroundColor = [UIColor whiteColor];
    
    [loginButton addTarget:self action:@selector(loginOut) forControlEvents:(UIControlEventTouchUpInside)];
}

- (void)loginOut {
    if (_loginOutAssion) {
        _loginOutAssion();
    }
}


- (void)setIsJion:(NSString *)isJion {
    _isJion = isJion;
    if ([_isJion isEqualToString:@"已加入"]) {
        [_loginButton setTitle:@"退出本群" forState:(UIControlStateNormal)];
    } else {
        [_loginButton setTitle:@"加入本群" forState:(UIControlStateNormal)];

    }
}

@end
